package day0213;

import java.util.concurrent.ExecutionException;

public class  Test{
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        Object laBa=new Object();

        Thread customer=new Thread(){
            public void run() {
                synchronized (laBa){
                    try {
                        laBa.wait();
                        //让t1线程插队到t2线程的前边
                        //(t1线程先运行，t1运行完毕t2线程才能运行)
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    for(int i=1;i<=10;i++){
                        System.out.println("吃包子"+i);
                    }
                }
            }
        };
        customer.start();

        Thread chuShi=new Thread(){
            public void run() {
                synchronized (laBa){
                    for(int i=10;i<=30;i++){
                        System.out.println("蒸包子："+i);
                    }
                    laBa.notify();
                }
            }
        };
        chuShi.start();

    }
}